import React from "react"
import ReactDOM from 'react-dom';
import {Row, Col, Avatar, Select, Divider, Tabs, Timeline, Modal, Icon, Button, Tag, Checkbox, message, Radio, Spin,
  BackTop, Tooltip} from 'antd'
import {messages, sortMenu} from 'share/common'
import menuRoute from 'routes/menuRoute'
import ListSort from 'components/list-sort'
import Condition from 'components/condition'
import PersonCards from 'containers/personal-setting/components/person-cards';
import PersonBankCards from 'containers/personal-setting/components/person-bank-cards';
import mainService from 'containers/main.service';

const {If} = Condition;
import moment from 'moment'
import "styles/personal-setting/personal-setting.scss"
import {connect} from "react-redux";
import baseService from "share/base.service";
import personalSettingService from 'containers/personal-setting/personal-setting.service'
import PersonalSettingForm from 'containers/personal-setting/personal-setting-form'

import UserMale from "images/user-male.png"
import UserFemale from "images/user-female.png"
import UserUnknow from 'images/user-unknow.png'
import NullDataImg from 'images/personal-setting/null-data.png'
import creditViewService from "containers/credit/credit-view/credit-view.service";

const Option = Select.Option;
const TabPane = Tabs.TabPane;

const MODE = {
  PERSONAL_MODE: false,
  ADMIN_MODE: true,
  TENANT_MODE: true,
  COMPANY_MODE: false
};
const commonFunc = {
  TENANT_MODE: {
    PERSONAL_MODE: [],
    ADMIN_MODE: []
  },
  COMPANY_MODE: {
    PERSONAL_MODE: [],
    ADMIN_MODE: []
  }
};

class PersonalSetting extends React.Component {
  constructor() {
    super();
    this.state = {
      loading: true,
      dataLoad: true,
      showModal: false,
      verifiCodeLoad: false,
      isEditing: true,
      adminMode: false,
      tenantMode: false,
      openKeys: [],
      menu: menuRoute.menu,
      selectedKey: null,
      animatedFlag: false,
      loginList: [],
      page: 0,
      pageSize: 20,
      total: 0,
      commonFunc: {
        TENANT_MODE: {
          PERSONAL_MODE: [],
          ADMIN_MODE: []
        },
        COMPANY_MODE: {
          PERSONAL_MODE: [],
          ADMIN_MODE: []
        },
      },
      basicInfo: {
        // fullName: "",
        // employeeID: 0,
        // mobile: "",
        // email: "",
        // departmentName: "",
        // gender: 0
      },
      userImg: {
        0: UserMale,
        1: UserFemale,
        2: UserUnknow
      },
      mobileStatus: null,
      modalTitle: null,
      modalContent: null,
      modalType: null,
      menuConfig: {},
      creditInfo: {},
      activeTab: "1"
    };
    this.tempMenuConfig = {};
    this.tempCommonFunc = {};
    this._onScrollEvent = this._onScrollEvent.bind(this);
    this._container = null;
  }

  componentWillMount() {
    // this.getMobileStatus();   已经存在account里mobileStatus字段
    this.getLoginLogList();
    this.getCreditView();
    this.initData();
  }

  initData = () => {
    this.setState({
      basicInfo: {...this.props.loginUser},
      tenantMode: this.props.tenantMode, //是否是集团模式的默认值
      mobileStatus: this.props.loginUser.mobileStatus,
      activeTab: this.props.location.query.tab ? this.props.location.query.tab : "1"
    }, () => {
      this.initSettingConfig();
    });
  };


  refreshUserInfo = () => {
    baseService.getUser().then(res => {
      this.setState({showModal: false});
      this.initData();
    }).catch(err => {
    })
  };

  getCreditView = () => {
    creditViewService.getUserCreditInfo().then(res => {
      this.setState({creditInfo: res.data})
    });
  };

  getLoginLogList = () => {
    const {page, pageSize, loginList} = this.state;
    personalSettingService.getLoginLogList(page, pageSize).then(res => {
      if (res.status === 200) {
        this.setState({
          loading: false,
          loginList: loginList.concat(res.data),
          total: Number(res.headers['x-total-count']) || 0
        }, () => {
          this.setState({dataLoad: true})
        })
      }
    })
  };

  handleCancel = () => {
    this.setState({showModal: false});
  };

  //初始化配置数据
  initSettingConfig = () => {
    const {tenantMode} = this.state;
    let menuConfigTemp = {};
    let commonFuncTemp = localStorage.getItem("hly.commonFunction") ? JSON.parse(localStorage.getItem("hly.commonFunction")) : commonFunc;
    if (localStorage.getItem(`hly.menuConfig.${tenantMode ? "tenantMode" : "companyMode"}`)) {
      menuConfigTemp = JSON.parse(localStorage.getItem(`hly.menuConfig.${tenantMode ? "tenantMode" : "companyMode"}`))
    } else {
      menuRoute.menu.map(item => {
        if (item.subMenu) {
          let subMenu = [];
          item.subMenu.map(item => subMenu.push(item.key));
          menuConfigTemp[item.key] = subMenu;
        } else {
          menuConfigTemp[item.key] = null
        }
      })
    }
    this.tempMenuConfig = JSON.parse(JSON.stringify(menuConfigTemp));
    this.tempCommonFunc = JSON.parse(JSON.stringify(commonFuncTemp));
    this.setState({menuConfig: menuConfigTemp, commonFunc: commonFuncTemp});
  };

  handleChangeLanguage = (value) => {
    if (value != this.props.language.code) {
      baseService.changeLanguage(value).then().catch(e => {
        this.setState({currentCode: this.props.language.code})
      });
    }
  };

  handleCheckMenu = (checkedValues) => {
    const {adminMode, tenantMode, commonFunc} = this.state;
    let tenantmode = tenantMode ? "TENANT_MODE" : "COMPANY_MODE";
    let adminmode = adminMode ? "ADMIN_MODE" : "PERSONAL_MODE";
    if (commonFunc[tenantmode].PERSONAL_MODE.length + commonFunc[tenantmode].ADMIN_MODE.length >= 20) {
      message.warning(messages('personal-setting.key23')/*常用功能个数已达上限，不能再添加*/);
    } else {
      commonFunc[tenantmode][adminmode] = checkedValues;
      this.setState({
        commonFunc: Object.assign({}, commonFunc)
      })
    }
  };

  saveCommonConfig = () => {
    const {tenantMode, menuConfig} = this.state;
    localStorage.setItem("hly.commonFunction", JSON.stringify(this.state.commonFunc));
    localStorage.setItem(`hly.menuConfig.${tenantMode ? "tenantMode" : "companyMode"}`, JSON.stringify(menuConfig));
    this.setState({
      // isEditing: false
    }, () => {
      this.initSettingConfig();
      Modal.success({
        title: messages('personal-setting.key24')/*小提示*/,
        content: messages('personal-setting.key25')/*您保存的设置将在您下一次刷新页面后生效哦*/,
      });
    })
  };

  handleClickMenu = menuItem => {
    const {selectedKey} = this.state;
    if (menuItem.subMenu) {
      this.setState({
        selectedKey: menuItem.key === selectedKey ? null : menuItem.key,
        animatedFlag: false
      }, () => this.setState({animatedFlag: true}))
    }
  };

  onCloseTag = (removedTag, adminmode) => {
    let tenantmode = this.state.tenantMode ? "TENANT_MODE" : "COMPANY_MODE";
    const tags = Object.assign({}, this.state.commonFunc);
    tags[tenantmode][adminmode] = tags[tenantmode][adminmode].filter(tag => tag !== removedTag);
    this.setState({
      commonFunc: tags
    })
  };

  handleSortMenu = (e) => {
    if (e.length) {
      const {menuConfig} = this.state;
      let menuList = [];
      let menuKeys = Object.keys(menuConfig);
      let tempMenuConfig = {};
      let tempNullMenuConfig = {};
      e.map((item) => {
        menuList.push(item.key);
      });
      menuList.map(item => {
        tempMenuConfig[item] = menuConfig[item] ? menuConfig[item] : null;
      });
      menuKeys.map(item => {
        if (menuList.indexOf(item) === -1) {
          tempNullMenuConfig[item] = menuConfig[item] ? menuConfig[item] : null;
        }
      });
      this.setState({menuConfig: {...tempMenuConfig, ...tempNullMenuConfig}});
    } else {
      return false;
    }
  };

  handleSortSubMenu = (e) => {
    if (e.length) {
      const {menuConfig} = this.state;
      let menuConfigTemp = {...menuConfig};
      let menuList = [];
      e.map((item) => {
        menuList.push(item.key);
      });
      menuConfigTemp[menuRoute.getMenuItemByAttr(this.state.selectedKey, 'key').key] = menuList;
      this.setState({menuConfig: menuConfigTemp});
    } else {
      return false;
    }
  };

  _onScrollEvent = () => {
    const {dataLoad, page, total} = this.state;
    let dom = ReactDOM.findDOMNode(this._container);
    if (dataLoad && (dom.childNodes.length < total) && (dom.scrollTop + dom.clientHeight > dom.childNodes[dom.childNodes.length - 1].offsetTop)) {
      this.setState({dataLoad: false, page: page + 1}, () => {
        this.getLoginLogList();
      });
    }
  };

  findScrollDom = () => {
    if (this._container) {
      return ReactDOM.findDOMNode(this._container);
    }
  };

  //渲染语言列表
  renderLanguageList = () => {
    if (this.props.languageList.length > 0) {
      return (
        <Select defaultValue={this.props.language.code} onChange={this.handleChangeLanguage}
                className="dropdown-list language-list">
          {this.props.languageList.map((item, index) => {
            return (<Option value={item.code.toLowerCase()} key={index}>{item.comments}</Option>)
          })}
        </Select>
      )
    } else {
      return (
        <Select defaultValue={this.props.language.locale} onChange={this.handleChangeLanguage}
                className="dropdown-list language-list">
          <Option value="zh_CN">简体中文</Option>
          <Option value="en">English</Option>
          <Option value="zh_TW">繁体中文</Option>
        </Select>
      )
    }
  };

  renderLoginLog = () => {
    const {loading, loginList} = this.state;
    return (
      <Spin spinning={loading}>
        <Timeline className="login-log"
                  ref={c => this._container = c}
                  onScrollCapture={() => this._onScrollEvent()}
                  pending={loading ? messages('personal-setting.key26')/*加载中...*/ : false}>
          {
            loginList.map(item => {
              return (
                <Timeline.Item color={item.status === 1001 ? "green" : "#FA541C"} key={item.id}>
                  <Row gutter={16} style={{marginLeft: 6}}>
                    <Col span={4}>
                      <p>{item.status === 1001 ? messages('personal-setting.key27')/*登录成功*/ :
                        <span style={{color: "#FA541C"}}>{messages('personal-setting.key28')/*登录失败*/}</span>}</p>
                    </Col>
                    <Col span={20}>
                      <p>
                        <span>{messages('personal-setting.key29')/*登录时间*/}：</span><span>{moment(item.createdDate).format("YYYY-MM-DD HH:mm:ss")}</span>
                      </p>
                      <p><span>{messages('personal-setting.key30')/*登录类型*/}：</span><span>{item.loginType}</span></p>
                    </Col>
                  </Row>
                </Timeline.Item>
              )
            })
          }
        </Timeline>
      </Spin>
    )
  };

  renderMenuList = menu => menu.filter((menuItem) => mainService.checkMenuAuth(menuItem, this.state.adminMode, this.state.tenantMode, this.props.isOldCompany)).map(item => (
    <div onClick={e => this.handleClickMenu(item)}
         className={`menu-item ${this.state.selectedKey === item.key && 'selected'} ${this.state.isEditing && 'cursor-move'} ${!this.state.isEditing && item.subMenu && 'cursor-point'}`}
         key={item.key}
    >
      <span>
        <span className="nav-icon"
              onMouseDown={e => e.stopPropagation()}
              style={this.state.isEditing && !item.subMenu ? {cursor: "pointer"} : {}}>
            {this.state.isEditing
              ?
              (item.subMenu ? <Icon type={item.icon} className="operate-icon"/> : <Checkbox value={item.key}/>)
              :
              <Icon type={item.icon} className="operate-icon"/>}
        </span>
        <span className="nav-text">{item.menuName ? item.menuName : messages(`menu.${item.key}`)}</span>
        {item.subMenu && <Icon type="right" className="arrow-right"/>}
      </span>
    </div>
  ));


  render() {
    const {basicInfo, isEditing, commonFunc, adminMode, tenantMode, menu, selectedKey, animatedFlag, menuConfig, showModal, modalTitle, modalType, mobileStatus, creditInfo, activeTab, userImg} = this.state;
    const {loginUser, loginCompany, user} = this.props;
    let tenantmode = tenantMode ? "TENANT_MODE" : "COMPANY_MODE";
    let adminmode = adminMode ? "ADMIN_MODE" : "PERSONAL_MODE";
    let totalLength = commonFunc[tenantmode].PERSONAL_MODE.length + commonFunc[tenantmode].ADMIN_MODE.length;
    return (
      <div className="personal-setting background-transparent">
        <Row gutter={20}>
          <Col span={6}>
            <div className="personal-box">
              <div className="basic-info">
                <Avatar style={{width: 64, height: 64, lineHeight: 64, borderRadius: 32}}
                        src={loginUser.filePath ? loginUser.filePath : userImg[loginUser.gender]}/>
                <p className="full-name">{basicInfo.fullName}</p>
                <p>{messages('common.user.id')/*工号*/}：{basicInfo.employeeID}</p>
              </div>
              <div className="personal-info">
                <div className="personal-info-head">
                  <h3>{messages('common.baseInfo')/*基本信息*/}</h3>
                </div>
                <div className="personal-info-content base-info">
                  <p className="info-list">
                    <Tooltip title={basicInfo.mobile ? basicInfo.mobile : ""}>
                     <span className="pull-left">
                     <span><Icon type="phone"/></span>
                       {basicInfo.mobile ? basicInfo.mobile : messages('personal-setting.key31')/*手机*/}
                      </span>
                    </Tooltip>
                    {loginCompany.enableMobileModify && (basicInfo.mobile && mobileStatus === "activated" ?
                      <span className="pull-right edit"
                            onClick={() => this.setState({
                              showModal: true,
                              modalTitle: messages('personal-setting.key32')/*修改手机号*/,
                              modalType: "EDIT_MOBILE"
                            })}> {messages('common.update')/*修改*/}
                     </span>
                      : (basicInfo.mobile && mobileStatus === "not.validate" ?
                          <span className="pull-right bind"
                                onClick={() => this.setState({
                                  showModal: true,
                                  modalTitle: messages('personal-setting.key33')/*验证手机号*/,
                                  modalType: "VERIFY_MOBILE"
                                })}> {messages('personal-setting.key34')/*验证*/}
                       </span>
                          :
                          <span className="pull-right bind"
                                onClick={() => this.setState({
                                  showModal: true,
                                  modalTitle: messages('personal-setting.key35')/*绑定手机号*/,
                                  modalType: "BIND_MOBILE"
                                })}> {messages('personal-setting.key36')/*绑定*/}
                         </span>
                      ))}
                  </p>
                  <p className="info-list">
                    <Tooltip title={basicInfo.email ? basicInfo.email : ""}>
                     <span className="pull-left">
                     <span><Icon type="mail"/></span>
                       {basicInfo.email ? basicInfo.email : messages('personal-setting.key37')/*邮箱*/}
                      </span>
                    </Tooltip>
                    {loginCompany.enableEmailModify && (basicInfo.email ?
                      <span className="pull-right edit"
                            onClick={() => {
                              this.setState({
                                showModal: true,
                                modalTitle: messages('personal-setting.key38')/*修改邮箱*/,
                                modalType: "EDIT_EMAIL"
                              });
                            }}> {messages('common.update')/*修改*/}
                     </span>
                      :
                      null)}
                  </p>
                  {basicInfo.departmentName &&
                  <p className="info-list">
                    <Tooltip title={basicInfo.departmentName ? basicInfo.departmentName : ""}>
                     <span className="pull-left" style={{width: "100%"}}>
                       <span><Icon type="idcard"/></span>
                       {basicInfo.departmentName}
                     </span>
                    </Tooltip>
                  </p>}
                  {typeof(basicInfo.gender) !== 'undefined' && basicInfo.gender !== 2 && <p className="info-list">
                   <span className="pull-left" style={{width: "100%"}}>
                     <span><Icon type="team"/></span>
                     {basicInfo.gender ? messages('personal-setting.key39')/*女*/ : messages('personal-setting.key40')/*男*/}
                     </span>
                  </p>}
                </div>
              </div>
              <Divider style={{display: 'none'}} dashed/>
              <div className="personal-info" style={{display: 'none'}}>
                <div className="personal-info-head">
                  <h3>{messages('personal-setting.key41')/*设置*/}</h3>
                </div>
                <div className="personal-info-content">
                  <div className="info-list">
                    <span className="pull-left">{messages('personal-setting.key42')/*语言切换*/}</span>
                    <span className="pull-right edit" style={{width: "40%", textAlign: "right"}}>
                     {this.renderLanguageList()}
                   </span>
                  </div>
                  <div className="info-list">
                    <span className="pull-left">{messages('personal-setting.key43')/*登录密码*/}</span>
                    <span className="pull-right edit"
                          onClick={() => {
                            this.setState({
                              showModal: true,
                              modalTitle: messages('personal-setting.key44')/*修改密码*/,
                              modalType: "MODIFY_PASSWORD"
                            });
                          }}> {messages('common.update')/*修改*/}
                   </span>
                  </div>
                </div>
              </div>
              <Divider style={{display: 'none'}}dashed/>
              <div className="personal-info" style={{display: 'none'}}>
                <div className="personal-info-head">
                  <h3>{messages('personal-setting.key45')/*信用*/}</h3>
                </div>
                <div className="personal-info-content">
                  <div className="info-list">
                   <span className="pull-left">
                     <span>{messages('credit.key13')/*信用分*/}</span>:
                     <span>
                       {creditInfo.score}
                       <If value={!!creditInfo.creditRank}>
                        ，<span className="credit-level">{creditInfo.creditRank}</span>级
                      </If>
                     </span>
                   </span>
                    <span className="pull-right edit"
                          onClick={() => this.context.router.push(menuRoute.getRouteItem('credit-view', 'key').url)}> {messages('common.view')/*查看*/}
                   </span>
                    <If value={!!creditInfo.creditRank}>
                      <div className="credit-desc">{messages('credit.key17')/*等级说明*/}：{creditInfo.rankComment}</div>
                    </If>
                  </div>
                </div>
              </div>
            </div>
          </Col>
          <Col span={18}>
            <div className="personal-box">
              <Tabs defaultActiveKey={activeTab}>
                <TabPane tab={messages('personal-setting.key46')/*登录日志*/} key="1">
                  <div className="tab-content">
                    {this.renderLoginLog()}
                    <BackTop target={() => this.findScrollDom()} visibilityHeight={400}/>
                  </div>
                </TabPane>
                <TabPane tab={messages('personal-setting.key67')/*银行卡*/} key="-1">
                  <PersonBankCards/>
                </TabPane>
                <TabPane tab={messages('personal-setting.key68')/*证件信息*/} key="0">
                  <PersonCards/>
                </TabPane>
                {!user.enableNewPermission && <TabPane tab={messages('personal-setting.key47')/*个性化设置*/} key="2">
                  <div style={{marginBottom: 10}}>
                    <div>
                      {this.hasAnyAuthorities(['ROLE_TENANT_ADMIN', 'ROLE_COMPANY_ADMIN'])
                      &&
                      <Select defaultValue={"PERSONAL_MODE"}
                              onChange={(e) => this.setState({adminMode: MODE[e], selectedKey: null})}
                              className="dropdown-list" style={{marginRight: 8}}>
                        <Option value="PERSONAL_MODE">{messages('personal-setting.key51')/*个人模式*/}</Option>
                        <Option value="ADMIN_MODE">{messages('personal-setting.key52')/*管理员模式*/}</Option>
                      </Select>}
                      {this.checkAuthorities('ROLE_TENANT_ADMIN')
                      && (
                        <Select defaultValue={this.props.tenantMode ? "TENANT_MODE" : "COMPANY_MODE"}
                                onChange={(e) => this.setState({tenantMode: MODE[e]}, () => this.initSettingConfig())}
                                className="dropdown-list">
                          <Option value="TENANT_MODE">{messages('personal-setting.key48')/*集团模式*/}</Option>
                          <Option value="COMPANY_MODE">{messages('personal-setting.key49')/*公司模式*/}</Option>
                        </Select>)}
                    </div>
                    <div>
                      <Button type="primary" style={{marginRight: 10}}
                              onClick={this.saveCommonConfig}>{messages("common.save")}</Button>
                    </div>
                  </div>
                  <div className="menu-list">
                    <Row>
                      <Col span={12}>
                        <h3>{messages('personal-setting.key50')/*个性化导航排序*/}</h3>
                        <p>{messages('personal-setting.key59')/*可上下移动菜单进行排序*/}</p>
                        <div className="menu-list-left">
                          <Checkbox.Group onChange={this.handleCheckMenu} value={commonFunc[tenantmode][adminmode]}>
                            <Row>
                              <Col span={12} style={{overflow: "hidden"}}>
                                {
                                  menu && menu.length && (
                                    isEditing ?
                                      <div className="menu-list-item">
                                        <ListSort onChange={(e) => this.handleSortMenu(e)}>
                                          {this.renderMenuList(sortMenu(menu, Object.keys(menuConfig)))}
                                        </ListSort>
                                      </div>
                                      :
                                      <div className="menu-list-item">
                                        {this.renderMenuList(sortMenu(menu, Object.keys(menuConfig)))}
                                      </div>
                                  )
                                }
                              </Col>
                              <Col span={12} style={{overflow: "hidden", padding: "0 0 0 10px"}}>
                                {selectedKey && animatedFlag && (
                                  isEditing ?
                                    <div className="menu-list-item">
                                      <ListSort onChange={(e) => this.handleSortSubMenu(e)}>
                                        {this.renderMenuList(sortMenu(menuRoute.getMenuItemByAttr(selectedKey, 'key').subMenu, menuConfig[selectedKey]))}
                                      </ListSort>
                                    </div>
                                    :
                                    <div className="menu-list-item">
                                      {this.renderMenuList(sortMenu(menuRoute.getMenuItemByAttr(selectedKey, 'key').subMenu, menuConfig[selectedKey]))}
                                    </div>
                                )}
                              </Col>
                            </Row>
                          </Checkbox.Group>
                        </div>
                      </Col>
                      <Col span={1} style={{textAlign: "center", paddingTop: "70px"}}>
                        <Divider type="vertical" style={{height: "calc(100vh - 340px)"}}/>
                      </Col>
                      <Col span={11}>
                        <h3>{messages('personal-setting.key54')/*常用功能*/}</h3>
                        {isEditing && <p>{messages('personal-setting.key60')/*勾选左边导航菜单即可添加常用功能，最多添加20个*/}</p>}
                        <div className="tag-box">
                          {
                            totalLength ? (
                              <div>
                                <div className={"tag-list"}>
                                  <h4>{messages('personal-setting.key61')/*个人常用*/}</h4>
                                  {
                                    commonFunc[tenantmode].PERSONAL_MODE.map((item) => {
                                      return (
                                        <Tag closable={isEditing}
                                             afterClose={() => this.onCloseTag(item, "PERSONAL_MODE")}
                                             key={item}>{messages(`menu.${item}`)}</Tag>
                                      )
                                    })
                                  }
                                </div>
                                {
                                  this.hasAnyAuthorities(['ROLE_TENANT_ADMIN', 'ROLE_COMPANY_ADMIN']) && (
                                    <div className={"tag-list"}>
                                      <h4>{messages('personal-setting.key62')/*管理员常用*/}</h4>
                                      {
                                        commonFunc[tenantmode].ADMIN_MODE.map((item) => {
                                          return (
                                            <Tag closable={isEditing}
                                                 afterClose={() => this.onCloseTag(item, "ADMIN_MODE")}
                                                 key={item}>{messages(`menu.${item}`)}</Tag>
                                          )
                                        })
                                      }
                                    </div>
                                  )}
                              </div>
                            ) : (
                              (isEditing && <div className="null-data">
                                <p><img src={NullDataImg}/></p>
                                <p>{messages('personal-setting.key63')/*暂无常用功能*/}</p>
                              </div>)
                            )
                          }
                        </div>
                      </Col>
                    </Row>
                  </div>
                </TabPane>}
              </Tabs>
            </div>
          </Col>
          <PersonalSettingForm
            visible={showModal}
            modalType={modalType}
            title={modalTitle}
            onCancel={this.handleCancel}
            onOk={this.refreshUserInfo}
          />
        </Row>

      </div>
    )
  }
}

PersonalSetting.contextTypes = {
  router: React.PropTypes.object
};

function mapStateToProps(state) {
  return {
    languageList: state.login.languageList,
    language: state.main.language,
    user: state.login.user,
    loginUser: state.login.loginUser,
    tenantMode: state.main.tenantMode,
    isOldCompany: state.login.isOldCompany,
    loginCompany: state.login.loginCompany
  }
}

export default connect(mapStateToProps)(PersonalSetting);
